package com.info.zhiduoduo.admin.model.dto.account;

import com.info.zhiduoduo.common.utils.DateUtil;
import com.info.zhiduoduo.repository.entity.system.MonthBusinessGross;

import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class MonthBusinessGrossDto {

	@ApiModelProperty("当前年份")
	private Integer year;
	@ApiModelProperty("当前季度 1,2,3,4")
	private Integer quarter;
	@ApiModelProperty("当前月份")
	private Integer month;

	@ApiModelProperty(" 交易额")
	private BigDecimal zddAmount;
	@ApiModelProperty("智众包交易额")
	private BigDecimal crowdsourceAmount;
	@ApiModelProperty(" 交易额")
	private BigDecimal taxerAmount;
	@ApiModelProperty("纯代理交易额")
	private BigDecimal agentTaxerAmount;
	@ApiModelProperty("委托接单交易额")
	private BigDecimal entrustAmount;
	@ApiModelProperty("创客团交易额")
	private BigDecimal makerGrouponAmount;
	@ApiModelProperty("交易额小计")
	private BigDecimal monthAmount;

	@ApiModelProperty("服务费")
	private BigDecimal serviceCharge;
	@ApiModelProperty("个税")
	private BigDecimal taxFee;
	@ApiModelProperty("增值税+附加税")
	private BigDecimal valueAddedTax;
	@ApiModelProperty("合伙人佣金")
	private BigDecimal brokerage;
	@ApiModelProperty("合计=服务费+个税+增值税")
	private BigDecimal sum;
	@ApiModelProperty("毛利=服务费-合伙人佣金")
	private BigDecimal gross;

	public static MonthBusinessGrossDto of(int year,  int month) {
		return new MonthBusinessGrossDto().setYear(year).setQuarter(DateUtil.getQuarterOfMonth(month)).setMonth(month);
	}

	public MonthBusinessGrossDto add(MonthBusinessGrossDto other) {
		this.serviceCharge =this.serviceCharge.add(other.serviceCharge);
		this.taxFee = this.taxFee.add(other.taxFee);
		this.valueAddedTax = this.valueAddedTax.add(other.valueAddedTax);
		this.sum = this.sum.add(other.sum);
		return this;
	}

	public MonthBusinessGross toEntity() {
		MonthBusinessGross entity = new MonthBusinessGross();
		BeanUtils.copyProperties(this, entity);
		return entity;
	}
}
